package org.meichao.hello.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
public class HelloTask {

    /**
     * cron表达式:
     *  [秒] [分] [小时] [日] [月] [周] [年] 注：[年]不是必须的域，可以省略[年]，则一共6个域
     *
     */
    @Scheduled(cron = "*/5 * * * * ?")
    public void hello(){
        System.out.println("hello world" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
    }

}
